home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
015a
/
env15w.zip
/
ENV.DOC
< prev
next >
Wrap
Text File
|
1991-10-15
|
15KB
|
415 lines
ENV - The Master Environment Utility
Version 1.5w
by
Kjell Eikland
674 St. John's Drive
Camp Hill, PA 17011
-----------------------------------------------------------------
ENV is a DOS environment utility which does everything the
internal SET command does, and much more. If these are new
concepts to you, then you may read quickly through the Appendix
that contains a description of what the environment is and what
the SET command does. ENV provides:
... a powerful calculator with a large complement of scientific
functions, date and time functions (with time zone
adjustments), and also logical operators.
... complete text manipulation functions, freely intermixable
with the mathematical calculation services.
... interactive editing of existing or new environment
variables, for example the content of the PATH.
... automatic prompting for input from the user.
... testing of environment variables with the result reported in
DOS's ERRORLEVEL variable.
... batch commands to speed the execution time and to quickly
insert new environment variables that may be stored in a
"library".
... selective listing and erasure of the environment's content
based on an extended use of the * and ? wild-cards.
... a simple report generator to facilitate the development of
useful routines, such as a DOS command line calculator.
... report generation to any DOS output file, device or pipe.
... provides full support for DOS input pipes, such that the DOS
commands SORT and FIND may be used to dramatically increase
the possible uses of ENV.
... free use of any environment present in your computer in
addition to the standard use of the master DOS environment.
... status information on the present environment, including the
owner's name.
Licencing information
---------------------
ENV is a Shareware program. That means you may try it out on
your computer for a limited period of time. If you find that you
would like to keep ENV on your computer, please send a check for
US$15.00 to the address given on the first page.
ENV is written and copyrighted by Kjell Eikland 1991.
----------------
Feedback welcome through Compuserve (CIS) 72461,556
Using ENV
General syntax
--------------
ENV uses the following command structure:
ENV [general command] [specific action]
The general commands are:
HELP Provide help for ENV
STATUS Show environment usage
LIST Display the content of the environment
EDIT Do interactive editing of a variable
ERASE Erase one or more variables
EXIST Test for the existence of a variable
CALC Compute the value of a text or mathematical
expression
ASK Interactively ask to define an environment
variable
SET Define the content of a variable
SET% As SET but add a leading and trailing %
TEST Test for equality
In its simplest form a mathematical calculation could be
performed by writing:
ENV SET TEST=(1+2)/3
ENV CALC TEST
ENV LIST TEST
ENV ERASE TEST
(Of course, this is better implemented in an ENV batch file so
that DOS does not have to reload ENV every time.) Similarly, a
simple text expression could be written:
ENV SET TEST=a+b+c+d+MID(efgh~2~2)
etc.
or with variable substitution:
ENV SET TEST=MID(%COMSPEC%~3~LENGTH(%COMSPEC%)-2)
etc.
Using redirection and piping
----------------------------
ENV supports redirection and piping for all of the relevant
commands. For example, the current directory may be retrieved by
writing:
CD|ENV SET CURDIR
The environment may be sorted, saved and restored with the
commands:
ENV LIST * SET {GET*NAME}={GET*VALUE}|SORT >ENVSAVE.TMP
ENV ERASE *
ENV BATCH <ENVSAVE.TMP
Similarly, a sorted listing of the environment may be printed by
writing:
ENV LIST *|SORT >PRN
If you wish to store the version of the operating system in an
environment variable you would type:
VER|FIND "Version"|ENV SET DOSVERSION
These are only some of the possible uses of redirection and
piping. Particularly together with DOS's FIND and type
utilities, as well as the enhanced ability of DOS 5.0 of scan
subdirectories, there is effectively no limit to the possible
uses of redirection and piping in ENV.
The use of wild-cards
---------------------
In certain situations, it is convenient or necessary to specify
more than one environment variable in one statement. In DOS, a
similar situation arises when you wish to have a directory
listing of more than one file - say of all files whose names
begin with the letter A. You would then type "DIR A*.*". If the
files of interest have names with three letters you would type
"DIR ???.*". DOS uses the character "*" to signify any character
or many characters. "?" signifies a character. Collectively,
"*" and "?" are called wild-cards.
The big problem with DOS's use of wild-cards wildcards is that
"*" may not be followed by a letter. That means that it is
impossible to have DOS list all files that end with an "E"; i.e.
the command "DIR *E.*" is incomprehensible to DOS.
With this introduction it is fairly obvious that ENV handles full
wild-card usage. Thus, if you wish to list all variables ending
with an "E" followed by two other letters you would write
"ENV LIST *E??". Both the ENV LIST and ENV ERASE commands use
this syntax.
Additionally, in the case of piped input (consult the section on
"Using DOS pipes and files with ENV" if this concept is new to
you) to the ENV SET command an entire file or listing may be
loaded into the environment with numbered lines. Two examples of
this usage:
DIR|SORT|ENV SET FILE* This would load the
environment with the names of
all files in the current
directory sorted
alphabetically, and given the
names FILE001, FILE002, etc.
TYPE CONFIG.SYS|ENV SET CFG* This would load the
environment with all lines in
the CONFIG.SYS file, numbered
consequtively.
Calculator operators and functions
----------------------------------
Math:
Operators Functions 1/0 Logic
+ Addition LN(■Number■) > Greater than
- Subtraction EXP(■Number■) < Less than
* Multiplication INT(■Number■) ≡ Equal to
/ Division FLOOR(■Number■) ≥ GT or EQ to
^ Exponentiation SIN(■Number■) ≤ LT or EQ to
√ n'th root ASIN(■Number■)
@ Modulo/remainder LRAND(■Number■)
÷ Integer division NRAND(■Number■)
!(■Number■)
GAMMA(■Number■)
CUMNORM(■Number■)
PI()
In addition to the SIN/ASIN functions, COS/ACOS and TAN/ATAN are
similarly defined. All trigonometric functions use radians.
Date:
TIMENOW(■Time Zone Offset■) Current time in HH.MMSS format
DATENOW(■Time Zone Offset■) Current date in YYYY.MMDD
format
DECTIME(■HMS time number■) Convert time to decimal format
HMSTIME(■DEC time number■) Convert time to HMS format
DAYS(■YYYY.MMDD day number■) Days since 15 Oct.1582 serial
number
YMD(■Date serial number■) Convert serial date to
YYYY.MMDD format
As an example, the expression DAYS(DATENOW())-DAYS(1918.1111)
would give the number of days since 11 november 1918. The
expression DATENOW(-3) would give the date in current time zone
less 3 hours.
Text:
LENGTH(■String■) Length of a string
POS(■Target■~■String■) Position of a
substring
MID(■String■~■StartPos■~■Chars■) Extract a substring
INSERT(■AddString■~■String■~■StartPos■) Insert a string into
a string
DELETE(■String■~■StartPos■~■Count■) Delete characters in
a string
UCASE(■String■) Convert string to
upper case
LCASE(■String■) Convert string to
lower case
ASC(■Character■) ASCII value of a
character
CHR(■AsciiValue■) Character of an
ASCII code
COPY(■Character■~■Count■) Replicate a
character
The expression MID(%COMSPEC%~1~2) would give the disk drive where
command processor COMMAND.COM is located. The expression
COPY(CHR(205)~LENGTH(%PATH%)) would create a string of ═'s with a
lenght equal to the current length of the PATH variable.
Internal:
{ENV*OWNER} Get the owner of the current environment
{ENV*SIZE} Retrieve the total size of the environment
{ENV*USED} Compute bytes currently used in the
environment
{ENV*COUNT} Total the current number of variables defined
{GET*DRIVE} Obtain the default/current disk drive
{GET*DIR} Obtain the default/current directory
{GET*NAME} Return the name of the currently active
variable
{GET*VALUE} Return the value of the currently active
variable
Accessing other than the master environment
-------------------------------------------
Any environment may be accessed by defining ENVLEVEL=■n■ in the
master environment, where ■n■ is an integer specifying the loaded
order of the desired program. The master environment may always
be accessed by ENV MASTER ■EnvCommand■.
By issuing the ENV STATUS command the name of owner of the
current environment will be displayed.
Appendix
The in's and out's of the SET command
SET is an internal DOS command which adds, changes or deletes
elements in the command processor's environment. Being an
internal command, you will not see a SET.COM or SET.EXE file in
any directory listing. The command processor is the program that
gives you the DOS prompt (i.e. A> or C>) where you can issue DOS
commands and start programs. Normally the command processor is a
file with the name COMMAND.COM.
The command processor (and all programs) have reserved a portion
of memory to store parameters that are necessary for the
execution of the program, or simply useful. This area of memory
is called the "environment". The command processor's environment
is called the "master environment" because it is the first
created and one that is always there as long as your computer is
turned on.
The master environment always contains two elements, namely
COMSPEC and PATH. In the simplest setup possible for your
computer these two elements have the values:
PATH=
COMSPEC=A:\COMMAND.COM
You may see the content of your master environment by typing SET
from the DOS prompt.
COMSPEC identifies where a program may find the command processor
and what it is called. In some installations the command
processor may have the name 4DOS.COM. PATH identifies where DOS
should look for programs when the program is not located in the
present directory. The peculiar thing about PATH is that it may
contain nothing (nothing to the right of the =-sign). Any other
relationship is removed if it doesn't contain anything.
Another standard element in the master environment is PROMPT. By
adding PROMPT to your environment you can change the way the
command processor prompts you for a command. If you type:
SET PROMPT=$P$G
the prompt would, for example, look like "A:\DATA>". Other
values for PROMPT are described in your DOS manual. By typing
SET, your environment would now contain:
PATH=
COMSPEC=A:\COMMAND.COM
PROMPT=$P$G
Please note the capitalization rules here. The identifier or
name of the variable (e.g. PATH or COMSPEC) are always
capitalized regardless how you typed them. The value on the
right hand side, however, will be copied as you type it. The
general format for using the SET command is then:
SET List all entries in the
environment.
SET <Name>=<Value> Define a new or replace an
existing relationship.
SET <Name>= Remove an entry in the
environment.
Generally, these possible usage options are summarized by:
SET [<Name>=[<Value>]]
where the square brackets indicate a user option. <Value> may be
any combination of valid letters and characters, but can also
contain environment variables! Now, how can you as a user make
use of environment variables? Some programs require that you
define certain environment variables, but because of DOS's rather
rudimentary batch command language and the limited capabilities
of the SET command the usefulness is relatively limited.
By enclosing the variable name between %-signs in a batch file
the value of that variable will be substituted. Many variables
may be substituted on the same line. For example, consider the
following segment of a batch file:
SET OLDPATH=%PATH%
SET PATH=C:\
ECHO Starting a secondary command processor
ECHO I'm using %COMSPEC% with the path %PATH%
%COMSPEC% /E:512
SET PATH=%OLDPATH%
SET OLDPATH=
The default size of the environment is between 128 and 180 bytes,
depending on the DOS version. You may specify a larger
environment using the SHELL command in the CONFIG.SYS setup file
(see your DOS manual). The maximum size of the environment is
32 kilobytes in DOS 3.2 and higher; enough for most purposes.
But every time you start a program, DOS will create a new (child)
environment for that program, leaving the command processor's
environment in the dust. All unused space will be eliminated in
the child environment. That means that the program essentially
receives a "dead-end" environment. In a multi-tasking world,
such as under Windows or DesqView, programs cannot communicate
through their respective environments. Windows even uses two
environments at the same time, neither of any use for the normal
user since they have been truncated and not easily accessible by
other programs or the SET command!
... until the appearance of ENV!